package exp4;

import java.util.Scanner;

public class Exp4_2 {
	public static void main(String[] args) {
		int[]b= {1,3,5,7,9,11,13,15,17,18,19,20};
		int[]c=new int[b.length+1];
		for (int i = 0; i < c.length-1; i++) {
			c[i]=b[i];
		}
		boolean f=false;
		int t=-1;
		Scanner s=new Scanner(System.in);
		System.out.println("输入整数：");
		int a=s.nextInt();
		for(int i =0;i<b.length;i++) {
			if(b[i]==a)
				f=true;
		}
		if(f==true) {
			System.out.println("输入的整数已在数组中存在！");
			for (int e : b) {
				System.out.printf("%-4d",e);
			}
		}
		else {
			for(int i =0;i<c.length;i++) {
				if(c[i]>a) {
					t=i;
					break;
				}
			}
			if(t!=-1) {
				for(int j=c.length-2;j>=t;j--) {
					c[j+1]=c[j];
				}
				c[t]=a;
				for (int e : c) {
					System.out.printf("%-4d",e);
				}
			}
			else {
				c[b.length]=a;
				for (int e : c) {
					System.out.printf("%-4d",e);
				}
			}
		}

	}
}
